﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Controls;

namespace devtm.Editor.TypeSelector.AttributeBuilder
{
    public class ContextAttributeBuilderElement : TreeViewItem, INotifyPropertyChanged
    {

        ContextAttributeBuilder _root;
        public ContextAttributeBuilderElement(ContextAttributeBuilder parent)
        {
            _root = parent;
            var i = new TitleChooseAttributeUserControl() { ContextAttributeBuilderElement = this };

            // recupe des elements de la liste
            i.DataContext = _root.SubListe;

            Header = i;

            _attributeSelected = new AttributeMap(this);
        }

        private AttributeMap _attributeSelected;
        public AttributeMap AttributeSelected
        {
            get { return _attributeSelected; }
            set
            {
                _attributeSelected = value;
                MyPropertyChanged("AttributeSelected");
            }
        }



        #region INotifyPropertyChanged

        protected void MyPropertyChanged(PropertyChangedEventArgs e)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(this, e);
        }

        protected void MyPropertyChanged(string propertyName)
        {
            MyPropertyChanged(new PropertyChangedEventArgs(propertyName));
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        public Type SelectItem
        {
            get { return _attributeSelected.AttributeSelected; }
            set
            {
                _attributeSelected.AttributeSelected = value;
                MyPropertyChanged("SelectItem");
            }
        }

        public ContextAttributeBuilder Root { get { return _root; } }


       
    }
}
